﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace KeyboardImageViewer
{
    /// <summary>
    /// Interaction logic for SearchBox.xaml
    /// </summary>
    public partial class SearchBox : Window
    {
        private ImageManager manager;

        public SearchBox(ImageManager manager, MainWindow window)
        {
            this.manager = manager;

            this.Owner = window;

            InitializeComponent();

            this.searchText.Text = this.manager.Search;
            this.searchText.SelectionStart = 0;
            this.searchText.SelectionLength = this.manager.Search.Length;

            this.searchFileName.IsChecked = this.manager.SearchFileName;

            this.searchTags.IsChecked = this.manager.SearchTags;

            this.searchText.Focus();
        }

        private void searchOk_Click(object sender, RoutedEventArgs e)
        {
            this.manager.RunSearch(this.searchText.Text, (bool)this.searchFileName.IsChecked, (bool)this.searchTags.IsChecked);

            this.DialogResult = true;
        }
    }
}
